package org.theonept.gwt.svg.widget;

import org.theonept.gwt.svg.dom.SVGDOMImpl;

import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.HasMouseOverHandlers;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Widget;

public class CircleSVG extends Widget implements HasMouseOverHandlers {
	public CircleSVG(int cx, int cy, int r) {
		setElement(SVGDOMImpl.createCircleElement(Document.get(), cx, cy, r));
		addMouseOverHandler(new MouseOverHandler() {

			@Override
			public void onMouseOver(MouseOverEvent event) {
				setRayon(getElement(), 6);

			}
		});

	}

	public native Element setRayon(Element svgElem, int r) /*-{

		svgElem.setAttributeNS(null, "r", r);

		return svgElem;
	}-*/;

	@Override
	public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
		return addDomHandler(handler, MouseOverEvent.getType());
	}

}
